;(function() {
		init_parsley();
		$('.datepicker').datepicker({format: 'yyyy-mm-dd',todayHighlight:true,clearBtn:true,autoclose:true , language:"zh-CN"});
		$.fn.modal.Constructor.prototype.enforceFocus = function () { };
		$('#select2-single').select2({
			ajax: {
		    url: "/gym/GymMember/ajax_gym_member",
		    dataType: 'json',
		    delay: 250,
		    type:"GET",
		    data: function (params) {
		      return {
		      	q: params.term, // search term
		        page: params.page,
				  order_id : $('#order_id').val()
		      };
		    },
		    processResults: function (data, params) {
		      params.page = params.page || 1;
		
		      return {
		        results: data.results,
		        pagination: {
		          more: (params.page * 30) < data.total_count
		        }
		      };
		    },
		    cache: true
		},
		placeholder: '请选择转入会员的姓名 或者 电话',
  		escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
 		minimumInputLength: 1,
  		//templateResult: formatRepo,
  		//templateSelection: formatRepoSelection
		});
		
	   	$("#form-submit").click(function(){
	   		var flag=$('#validate-form').parsley('validate' );
	   		if(flag){
	   			loading();
	   			$.post(
	   				"/gym/GymMember/member_trans_post",
	   				$("#validate-form").serialize(),
	   				function(data){
	   					close_loading();
			      		if(data.flag){
			      			$("#myModal").modal("hide");
			      			toastr['success']("操作成功！", ''); 
			      			$("#myform #btn-advanced-refresh").trigger("click");// 刷新页面
			      		}else{
			      		 	toastr['error'](data.msg,"操作失败！"); 
			      		}
	   				}
	   			);
	   		}
	   	})
})();